import React, { Component } from 'react'
import { Picker, List, WhiteSpace, InputItem, Radio } from 'antd-mobile';
import '../assets/style/White_Say/gpicker.less'

const RadioItem = Radio.RadioItem;

export default class gpicker extends Component {
    constructor(props) {
        super(props)
        this.state = {
            data: [],
            asyncValue: [],
            isredio: 0



        }
        this.onPickerChange = this.onPickerChange.bind(this)
        this.onClick = this.onClick.bind(this)
        this.onclicent = this.onclicent.bind(this)
        this.onRedio = this.onRedio.bind(this)
    }

    onPickerChange(e) {
        console.log(e, 111)
        this.setState({
            asyncValue: e
        })
    }
    onClick(e) {
        console.log(e, 5555)
    }
    onclicent(e) {
        console.log(e, 8888)
        console.log(this.props.site)
        e.history.push(this.props.site)
    }
    onRedio = (e) => {
        console.log(e)
    }
    render() {
        return (<>
            {(() => {
                switch (this.props.type) {
                    case 'skip':
                        return (<div className="gnopicker_box" style={this.props.sty} onClick={() => this.onclicent(this.props.routes)}>
                            <div className="gpicker_left">
                                <div className="gpicker_left1">{this.props.title}</div>
                                <div className="gpicker_left2">{this.props.nickname}</div>
                            </div>
                            <div className="gpicker_right"><span className="iconfont icon-xiangyou"></span></div>
                        </div>)
                        break;
                    case 'antd':
                        return (<div className="gpicker_antd"><div className="gpicker_box">  <span className="gpicker_title">{this.props.title}</span></div>
                            <Picker
                                extra="请选择"
                                cols="1"
                                data={this.props.data}
                                value={this.state.asyncValue}
                                onOk={this.onPickerChange}
                            >
                                <List.Item arrow="horizontal" onClick={this.onClick}> </List.Item>
                            </Picker></div>)
                        break
                    case 'inpu':
                        // return (<div className="inpu_box" style={this.props.sty}>
                        //     <div className="inpu_title">{this.props.title}</div>
                        //     <div className="inpu_in">
                        //         <div className="inpu_inpu"><input type="text" placeholder="请选择" /></div>
                        //         <div className="inpu_inte">{this.props.icon}</div>
                        //     </div>
                        // </div>)

                        return (<div className="inpu_box" style={this.props.sty}>
                            <div className="inpu_title">{this.props.title}</div>
                            <div className="inpu_in">
                                <div className="inpu_inpu">
                                    <InputItem
                                        type='money'
                                        placeholder={'请选择'}
                                        clear
                                        moneyKeyboardAlign="left"
                                        onChange={(v) => { console.log('onChange', v); }}
                                        onBlur={(v) => { console.log('onBlur', v); }}
                                    ></InputItem>
                                </div>
                                <div className="inpu_inte">{this.props.icon}</div>
                            </div>
                        </div>)
                        break
                    case 'inputext':
                        return (<div className="inpu_box" style={this.props.sty}>
                            <div className="inpu_title">{this.props.title}</div>
                            <div className="inpu_in">
                                <div className="inpu_inpu"><input type="text" onChange={this.props.onChange} placeholder="请选择" /></div>
                                <div className="inpu_inte"><span className="iconfont icon-xiangyou"></span></div>
                            </div>
                        </div>)
                        break
                    case 'choice':
                        return (<div className="choice" style={this.props.sty} >
                            <div className="choice_title">{this.props.title}</div>
                            <div className="choice_s">
                                {this.props.data.map((v, index) => {
                                   return (<div className={v.isopt==true? 'choice_true':'choice_redio'} onClick={() => { this.props.addTodo(v) }} key={index} >{v.val}天</div>)
                                })}
                            </div>
                        </div>)
                        break
                    default:
                        break;
                }
            })()}
        </>



        )
    }

}




















  // <>{
            //     this.props.data ? <><div className="gpicker_box">  <span className="gpicker_title">{this.props.title}</span></div>
            //         <Picker
            //             extra="请选择"
            //             cols="1"
            //             data={this.props.data}
            //             value={this.state.asyncValue}
            //             onOk={this.onPickerChange}
            //         >
            //             <List.Item arrow="horizontal" onClick={this.onClick}> </List.Item>
            //         </Picker></> : <div className="gnopicker_box" onClick={() => this.onclicent(this.props.routes)}>
            //         <div className="gpicker_left">
            //             <div className="gpicker_left1">{this.props.title}</div>
            //             <div className="gpicker_left2">{this.props.nickname}</div>
            //         </div>
            //         <div className="gpicker_right"><span className="iconfont icon-xiangyou"></span></div>
            //     </div>
            // }
            // </>